package com.dxysun.mybatis.spring;

import com.alibaba.fastjson.JSON;
import com.dxysun.mybatis.spring.dao.IUserDao;
import com.dxysun.mybatis.spring.domain.User;
import com.dxysun.mybatis.spring.mapper.UserMapper;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.List;

public class Main
{
	public static void main(String[] args)
	{
		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:applicationContext.xml");

		UserMapper userMapper = applicationContext.getBean(UserMapper.class);
//		System.out.println(userMapper.selectUserByName("zhangsan"));
		/*for(int i = 0;i < 50; i++)
		{
			User user = new User();
			user.setUserName("name" + i);
			user.setRealName("real" + i);
			user.setPassword("123" + i);
			userMapper.insertUser(user);
		}*/

		List<User> userList = userMapper.selectUserList1(3, 10);
		System.out.println(JSON.toJSONString(userList));
//		System.out.println(userMapper.selectUserById(4));
//		System.out.println(userMapper.selectUserByName("zhangsan"));
		/*IUserDao userDao = applicationContext.getBean(IUserDao.class);
		List<User> userList = userDao.selectAll();
		userList.forEach(System.out::println);*/
	}
}
